home *** CD-ROM | disk | FTP | other *** search
- Path: cdshub.cdc.com!usenet
- From: Dave Misch <dmisch@dtrhp01.dtr.cdc.com>
- Newsgroups: comp.lang.c
- Subject: Re: Fortran to C conversion help?
- Date: Mon, 04 Mar 1996 13:56:17 -0500
- Organization: Control Data Corporation
- Message-ID: <313B3CD1.540F@dtrhp01.dtr.cdc.com>
- References: <4hf04k$ogs@pipe3.nyc.pipeline.com>
- NNTP-Posting-Host: dtrhp01.dtr.cdc.com
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0 (X11; I; HP-UX A.09.07 9000/735)
-
- Doug Kolmar wrote:
- >
- >
- > Hello folks,
- >
- > I'm sort of a weekend C programmer so perhaps I've missed something, but
- > I'm trying to convert a function in FORTRAN to C.
- >
- > Attached is the FORTRAN code followed by the C code that I've written. The
- > C program will compile and run, but does not yield the correct output. I.E.
- > integers in the range 0 to 31.
- >
- > Except for the differences in the range of the RAND functions, I know
- > nothing about FORTRAN, so am I missing something implicit in the code? Any
- > help would be greatly appreciated.
- >
- > Doug Kolmar
- > dkmar@panix.com
-
-
- For starters here are some ideas....
-
- k and new are probably not floats (use int)
-
- don't change the logic of the code - keep the gotos, get rid of the
- while loop.
- (if it aint broke don't fix it). All of that fortran has a C workalike.
-
- Make you main function call the C function - dont stick the function in
- the main.
-
- Don't seed the random every time - seed it only once.
-
-
- Good Luck
-